package com.wzx.user.controller;

import com.wzx.common.core.controller.AbstractCoreController;
import com.wzx.common.pojo.resp.Result;
import com.wzx.user.dto.BindingDto;
import com.wzx.user.pojo.Binding;
import com.wzx.user.service.BindingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wzx
 * @version 1.0
 * @date 2023/3/11 - 14:37
 * @description 标题
 */
@Slf4j
@RestController
@RequestMapping("/binding")
@Api(tags = "提现绑定管理")
public class BindingController extends AbstractCoreController<Binding> {

    @Autowired
    private BindingService bindingService;

    @Autowired
    protected BindingController(BindingService bindingService) {
        super(bindingService);
        this.bindingService = bindingService;
    }


    @PostMapping("/insertBinding")
    @ApiOperation(value = "绑定")
    public Result<Boolean> insertBinding(@RequestBody Binding binding) throws Exception {
        Boolean b = bindingService.insertBinding(binding);
        return Result.ok(b);
    }

    @GetMapping("/queryIsBinding")
    @ApiOperation(value = "查询用户是否绑定过提现账号")
    public Result<BindingDto> queryIsBinding(Integer userId) throws Exception {
        BindingDto bindingDto = bindingService.queryIsBinding(userId);
        return Result.ok(bindingDto);
    }

    @PostMapping("/queryBindingByIdCard")
    @ApiOperation(value = "判断身份证 手机号信息是否正确")
    public Result<Boolean> queryBindingByIdCard(@RequestBody Binding binding) throws Exception {
        Boolean b = bindingService.queryBindingByIdCard(binding);
        return Result.ok(b);
    }

    @PostMapping("/secureBinding")
    @ApiOperation(value = "解除绑定")
    public Result secureBinding(@RequestBody Binding binding) throws Exception {
        bindingService.secureBinding(binding);
        return Result.ok();
    }


}
